import sqlite3

from configs.basic_config import DB_PATH

# 连接到数据库
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()

# 检查表结构
print("Hotels table structure:")
cursor.execute('PRAGMA table_info(hotels)')
for row in cursor.fetchall():
    print(row)

# 检查是否有数据
print("\nTotal hotels in database:")
cursor.execute('SELECT COUNT(*) FROM hotels')
count = cursor.fetchone()[0]
print(count)

# 检查上海的酒店
print("\nHotels in Shanghai:")
cursor.execute('SELECT * FROM hotels WHERE location LIKE "%上海%"')
shanghai_hotels = cursor.fetchall()
for hotel in shanghai_hotels:
    print(hotel)

# 检查价格等级
print("\nPrice tiers in database:")
cursor.execute('SELECT DISTINCT price_tier FROM hotels')
tiers = cursor.fetchall()
for tier in tiers:
    print(tier)

# 检查上海的豪华酒店
print("\nLuxury hotels in Shanghai:")
cursor.execute('SELECT * FROM hotels WHERE location LIKE "%上海%" AND price_tier = "豪华"')
luxury_shanghai = cursor.fetchall()
for hotel in luxury_shanghai:
    print(hotel)

conn.close()